package ch.bfh.medinfo.smartsmsspeaker.device;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
//Permissions needed:
//<uses-permission android:name="android.permission.BATTERY_STATS" />

//Intent-filters needed:
//<action android:name="android.intent.action.BATTERY_LOW" />
//<action android:name="android.intent.action.BATTERY_OKAY" />
//

//If unsure check:
//http://developer.android.com/training/monitoring-device-state/battery-monitoring.html
public class BatteryStatusReceiver extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {

		if (intent == null) {
			return;
		}
		if (intent.getAction().equals(Intent.ACTION_BATTERY_LOW)) {		
			Log.i("ch.bfh.medinfo", "battery low");
			//Remember this status
			//Do something (calling a service which informs a person per SMS)
		}
		if (intent.getAction().equals(Intent.ACTION_BATTERY_OKAY)) {			
			Log.i("ch.bfh.medinfo", "battery ok");
			//Remember this status
			//Do something (calling a service which informs a person per SMS)
		}
	}
}
